import logging

from config import BASE_HOST


class RechargeApi:

    def __init__(self,session):
        # 接收session对象的变量
        self.session1 = session

    # 获取充值验证码接口
    def get_recharge_verify_code(self,r):
        url = BASE_HOST + '/common/public/verifycode/{}'.format(r)
        res = self.session1.get(url)
        return res

    # 充值接口
    def recharge(self,body):
        res = self.session1.post(url= BASE_HOST + '/trust/trust/recharge',data=body)
        logging.info('充值接口返回的内容{}'.format(res.json()))
        return res

        # 定义一个字典变量，用来接收请求体数据
    # 第三方充值接口
    def third_recharge(self,url,data):
        res = self.session1.post(url=url,data=data)
        logging.info(f'充值接口返回的内容{res.text}')
        return res


